import Vue from 'vue'
import Vuex from 'vuex'
import axios from "../http/http.js";
import route from "../routes.js";

import test from "./modules/testStore.js";
import common from "./../../common.js"

Vue.prototype.$axios = axios;
Vue.use(Vuex)


export default new Vuex.Store({
    namespaced: true,
    modules: {
        test
    },
    // strict: debug,
    // plugins: debug ? [createLogger()] : []
	// {{$store.state.unreadmsg.businessManager[0].companyInfo}}页面展示中用来获取数据的模板
	state:{
		telMark:false,
		overForm:{},
		welfare: [
		        {
		            code: 0,
		            name: "带薪年假"
		        },
		        {
		            code: 1,
		            name: "五险一金"
		        },
		        {
		            code: 2,
		            name: "专业培训"
		        },
		        {
		            code: 3,
		            name: "绩效奖金"
		        },
		        {
		            code: 4,
		            name: "包吃"
		        },
		        {
		            code: 5,
		            name: "包住"
		        },
		        {
		            code: 6,
		            name: "包吃包住"
		        },
		        {
		            code: 7,
		            name: "餐饮补贴"
		        },
		        {
		            code: 8,
		            name: "节日福利"
		        },
		        {
		            code: 9,
		            name: "弹性工作"
		        },
		        {
		            "code": "10",
		            "name": "全勤奖"
		        },
		        {
		            code: 11,
		            name: "交通补贴"
		        },
		        {
		            code: 12,
		            name: "出国机会"
		        },
		        {
		            code: 13,
		            name: "年终奖金"
		        },
		        {
		            code: 14,
		            name: "员工旅游"
		        },
		        {
		            code: 15,
		            name: "通讯补贴"
		        },
		        {
		            code: 16,
		            name: "大小周"
		        },
		        {
		            code: 17,
		            name: "定期体检"
		        },
		        {
		            code: 18,
		            name: '股票期权'
		        },
		        {
		            code: 19,
		            name: "出差补贴"
		        },
		        {
		            code: 20,
		            name: "六险一金"
		        },
		        {
		            code: 21,
		            name: "补充公积金"
		        },
		        {
		            code: 22,
		            name: "团建活动"
		        },
		        {
		            code: 23,
		            name: "加班补贴"
		        },
		        {
		            code: 24,
		            name: "周末双休"
		        },
		        {
		            code: 25,
		            name: "补充医保"
		        },
		        {
		            code: 26,
		            name: "加班调休"
		        },
		        {
		            code: 27,
		            name: "免费班车"
		        }
		    ],
		education:[
			{
				code:1,
				name:"初中",
			},{
				code:2,
				name:'高中'
			},{
				code:3,
				name:'中技'
			},{
				code:4,
				name:'中专'
			},{
				code:5,
				name:'大专'
			},{
				code:6,
				name:'本科'
			},{
				code:7,
				name:'硕士'
			},{
				code:8,
				name:'MBA'
			},{
				code:9,
				name:'博士'
			},{
				code:10,
				name:'学历未知'
			},{
				code:0,
				name:'学历不限'
			},{
				code:9999,
				name:'学历不限'
			}
		],
		workExperiencePosition: [
		    {
		        code: "",
		        name: "全部",
		        subLevelModelList: null
		    },
		    {
		        code: "9999",
		        name: "工作经验不限",
		        subLevelModelList: null
		    },
		    {
		        code: "0000",
		        name: "无经验",
		        subLevelModelList: null
		    },
		    {
		        code: "0103",
		        name: "1-3年",
		        subLevelModelList: null
		    },
		    {
		        code: "0305",
		        name: "3-5年",
		        subLevelModelList: null
		    },
		    {
		        code: "0510",
		        name: "5-10年",
		        subLevelModelList: null
		    },
		    {
		        code: "1099",
		        name: "10年以上",
		        subLevelModelList: null
		    }
		],
		salary:[{
			label:1,
			name:'1千以下/月'
		},{
			label:2,
			name:'1千-2千/月'
		},{
			label:3,
			name:'2千-3千/月'
		},{
			label:4,
			name:'3千-4千/月'
		},{
			label:5,
			name:'4千-5千/月'
		},{
			label:6,
			name:'5千-6千/月'
		},{
			label:7,
			name:'6千-8千/月'
		},{
			label:8,
			name:'8千-1万/月'
		},{
			label:9,
			name:'1万-1.5万/月'
		},{
			label:10,
			name:'1.5万-2万/月'
		},{
			label:11,
			name:'2万-2.5万/月'
		},{
			label:12,
			name:'2.5万-3万/月'
		},{
			label:13,
			name:'3万-3.5万/月'
		},{
			label:14,
			name:'3.5万-4万/月'
		},{
			label:15,
			name:'4万-4.5万/月'
		},{
			label:16,
			name:'4.5万-5万/月'
		},],
		form:{},
		unreadmsg:{						//消息未读气泡
			businessManager:[			//企业管理
				{companyInfo: []},		//企业信息审核
				{qualityCompany: []},	//优质企业审核
				{famousCompany: []},	//知名企业审核
				{postManagement: []	},	//岗位管理
				{businessAccount: []}	//对公账户审核
			]					
	
		},
		curBranchId:'',					//家政设置门店id
		pageTitle: '',					//电话招聘页面标题
	},
	mutations: {
		setform(state,form){
			state.form = form;
		},
		telValue(state,newVal){
		state.telMark=newVal
		},
		overForm(state,newVal){
		state.overForm=newVal
		},
		setBusinessManager(state,{type,data}){
			let msg = state.unreadmsg.businessManager;
			switch (type){
				case 1:
					Vue.set(msg[0],'companyInfo',data);
					break;
				case 2:
					Vue.set(msg[1],'qualityCompany',data);
					break;
				case 3:
					Vue.set(msg[2],'famousCompany',data);
					break;
				case 4:
					Vue.set(msg[3],'postManagement',data);
					break;
				case 5:
					Vue.set(msg[4],'businessAccount',data);
					break;
			}
		},
		setCurBranchId(state,data){
			state.curBranchId = data;
		},
		setPageTitle(state,data){
			state.pageTitle = data;
		}
	},
	actions: {
		async getBusinessManager({state,commit},type){
			let data = await common.getList(type,0);
			/* console.log(data);
			data = data.list; */
			commit('setBusinessManager',{
				type,
				data
			})
		},
		setCurBranchId({commit,state}, name){
			// 跟后台打交道
			// 调用mutaions里面的方法
			commit("setCurBranchId", name);
		},
		setPageTitle({commit,state},name){
			//设置页面标题
			commit("setPageTitle",name);
		}
	},
	getters:{
		businessManager(state){
			return state.unreadmsg.businessManager;
		},
		getCurBranchId(state){
			return state.curBranchId;
		},
		getPageTitle(state){
			return state.pageTitle;
		}
	},
})